package com.example.android.commitcontent.ime.keyboard.adapters;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.widget.TextView;

import com.example.android.commitcontent.ime.R;
import com.example.android.commitcontent.ime.cores.adapters.BaseSingleChooseAdapter;

import java.util.List;

import com.example.android.commitcontent.ime.beans.PinYinCharacter;

/**
 * 拼音键盘点击弹出更多列表的adapter
 */
public class MoreKeysAdapter extends BaseSingleChooseAdapter<PinYinCharacter> {

    {
        mCurrentSelectedPosition = 0;
    }

    public MoreKeysAdapter(Context context, int layoutRes, List<PinYinCharacter> dataList) {
        super(context, layoutRes, dataList);
    }

    public MoreKeysAdapter(Context context, int layoutRes, List<PinYinCharacter> dataList, int checkEventViewId) {
        super(context, layoutRes, dataList, checkEventViewId);
    }

    public MoreKeysAdapter(Context context, int layoutRes, List<PinYinCharacter> dataList, int checkEventViewId, int defaultSelectedPosition) {
        super(context, layoutRes, dataList, checkEventViewId, defaultSelectedPosition);
    }

    @Override
    protected void onBindData(@NonNull PinYinCharacter data, @NonNull Holder holder, int position) {
        TextView title = holder.findViewById(R.id.tv_title);
        title.setText(data.text);
        if (getSelectedPosition() == position) {
            holder.itemView.setBackgroundResource(R.drawable.bg_key_more_selected);
            title.setTextColor(Color.WHITE);
        } else {
            holder.itemView.setBackgroundColor(Color.TRANSPARENT);
            title.setTextColor(Color.parseColor("#333333"));
        }
    }
}
